package com.wwwarehouse.dubbo;

import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.Arrays;
import java.util.Map;

@SpringBootApplication
public class DubboSpringApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(DubboSpringApplication.class);
        Map<String, Object> beansWithAnnotation = context.getBeansWithAnnotation(Service.class);
        beansWithAnnotation.values().stream().forEach(bean -> {
            System.out.println(bean.getClass().getInterfaces());
            System.out.println(bean.getClass().getInterfaces()[0].getName());
            Method[] methods = bean.getClass().getDeclaredMethods();
            Arrays.stream(methods).forEach(method -> {
                System.out.println(method.getName());
                Parameter[] params = method.getParameters();
                Arrays.stream(params).forEach(parameter -> System.out.println(parameter.getName() + ":"+parameter.getParameterizedType().getTypeName()));
            });
        });
    }
}
